﻿<UserControl x:Class="EditZone"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:system="clr-namespace:System;assembly=mscorlib" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
            xmlns:local="clr-namespace:OMANE.Modules.Indicateurs"
             
   HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="GhostWhite"
             >
    <!--Width="{Binding GraphDefinition.Width}" Height="{Binding GraphDefinition.Height}"
    <UserControl.HorizontalAlignment>
        <Binding Path="GraphDefinition.HAlign" Mode="OneWay" FallbackValue="Stretch" >
            <Binding.Converter>
                <local:ObjectHorizontalAlignmentConverter />
            </Binding.Converter>
        </Binding>
    </UserControl.HorizontalAlignment>
    
    
    <UserControl.VerticalAlignment>
        <Binding Path="GraphDefinition.VAlign" Mode="OneWay" FallbackValue="Stretch">
            <Binding.Converter>
                <local:ObjectVerticalAlignmentConverter/>
            </Binding.Converter>
        </Binding>
    </UserControl.VerticalAlignment>-->

    <UserControl.Resources>
        <Style x:Key="ThumbSizeStyle" TargetType="Thumb">
            <Setter Property="Visibility">
                <Setter.Value>
                    <Binding Path="IsMouseOver" ElementName="root">
                        <Binding.Converter>
                            <BooleanToVisibilityConverter />
                        </Binding.Converter>
                    </Binding>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Thumb">
                        <Rectangle Fill="Black"  />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <GridLength x:Key="ThumbSize">Auto</GridLength>
        <system:Double x:Key="ThumbSizeAbs">3</system:Double>

        <local:ColorBrushConverter x:Key="ColorBrushConverter" />
        <local:DoubleCornerRadiusConverter x:Key="DoubleCornerRadiusConverter" />
        <local:DoubleThicknessConverter x:Key="DoubleThicknessConverter" />

        <local:ObjectVerticalAlignmentConverter x:Key="ObjectVerticalAlignmentConverter" />
        <local:ObjectHorizontalAlignmentConverter x:Key="ObjectHorizontalAlignmentConverter" />
    </UserControl.Resources>
    <UserControl.Template>
        <ControlTemplate TargetType="ContentControl">
            <ContentPresenter ContentSource="Content" />
        </ControlTemplate>
    </UserControl.Template>
    <UserControl.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Copier" Click="MenuItem_Click"/>
            <MenuItem Header="Couper" />
            <MenuItem Header="Coller" />
             
        </ContextMenu>
    </UserControl.ContextMenu>
        <Grid Name="root">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{StaticResource ThumbSize}" />
            <ColumnDefinition  />
            <ColumnDefinition Width="{StaticResource ThumbSize}" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="{StaticResource ThumbSize}" />
            <RowDefinition  />
            <RowDefinition Height="{StaticResource ThumbSize}" />
        </Grid.RowDefinitions>

        <Thumb Grid.Column="0" Grid.Row="0" Style="{DynamicResource ThumbSizeStyle}" />
        <Thumb Width="{DynamicResource ThumbSizeAbs}" Name="lcthumb" Grid.Column="0" Grid.Row="1" Style="{DynamicResource ThumbSizeStyle}"  Cursor="SizeWE" DragDelta="Thumb_DragDelta"/>
        <Thumb Grid.Column="0" Grid.Row="2" Style="{DynamicResource ThumbSizeStyle}" />
        <Thumb Height="{DynamicResource ThumbSizeAbs}" Name="ctthumb" Grid.Column="1" Grid.Row="0" Style="{DynamicResource ThumbSizeStyle}"  Cursor="SizeNS" DragDelta="Thumb_DragDelta"/>
        <Thumb Name="ccthumb" Grid.Column="1" Grid.Row="1" MouseDoubleClick="Thumb_MouseDoubleClick" Cursor="ScrollAll" DragDelta="Thumb_DragDelta" >
            <Thumb.Template>
                <ControlTemplate TargetType="Thumb">
                    <!--<Border 
                       Background="{Binding  GraphDefinition.BackColor, Converter={StaticResource ColorBrushConverter}, Mode=OneWay}" 
                        BorderBrush="{Binding  GraphDefinition.BorderColor, Converter={StaticResource ColorBrushConverter}, Mode=OneWay}" 
                        BorderThickness="{Binding  GraphDefinition.BorderSize, Converter={StaticResource DoubleThicknessConverter}, Mode=OneWay}" 
                        CornerRadius="{Binding  GraphDefinition.CornerRadius, Converter={StaticResource DoubleCornerRadiusConverter}, Mode=OneWay}"  />-->
<!-- 
                        Stroke="{Binding BorderColor, Converter={StaticResource ColorBrushConverter}, Mode=OneWay}"-->
                    <!--<Rectangle Fill="{Binding GraphDefinition.BackColor, Converter={StaticResource ColorBrushConverter}, Mode=OneWay}"
                         />-->
                    <!--->-<Rectangle Fill=/>-->
                   <!--<Border 
                       Background="{Binding RelativeSource={RelativeSource AncestorType=local:EditZone}, Path=Background}" 
                       BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:EditZone}, Path=BorderBrush}" 
                       />-->
                    <Grid>
                    <Rectangle 
                        Fill="{Binding RelativeSource={RelativeSource AncestorType=local:EditZone}, Path=Background}"
                        Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:EditZone}, Path=BorderBrush}"
                        RadiusX="{Binding RelativeSource={RelativeSource AncestorType=local:EditZone}, Path=CornerRadius}"
                        RadiusY="{Binding RelativeSource={RelativeSource AncestorType=local:EditZone}, Path=CornerRadius}"
                        StrokeThickness="{Binding RelativeSource={RelativeSource AncestorType=local:EditZone}, Path=BorderSize}"
                      />
                        <ContentPresenter 
                            Margin="{Binding RelativeSource={RelativeSource AncestorType=local:EditZone}, Path=BorderSize, Converter={StaticResource DoubleThicknessConverter}}" 
                            Content="{Binding GraphDefinition.DetailInstance}"/>
                    </Grid>
                </ControlTemplate>
            </Thumb.Template>
        </Thumb>
        <Thumb Height="{DynamicResource ThumbSizeAbs}" Name="cbthumb" Grid.Column="1" Grid.Row="2" Style="{DynamicResource ThumbSizeStyle}" Cursor="SizeNS" DragDelta="Thumb_DragDelta"/>
        <Thumb Grid.Column="2" Grid.Row="0" Style="{DynamicResource ThumbSizeStyle}"/>
        <Thumb Width="{DynamicResource ThumbSizeAbs}" Name="rcthumb" Grid.Column="2" Grid.Row="1" Style="{DynamicResource ThumbSizeStyle}"  Cursor="SizeWE" DragDelta="Thumb_DragDelta"/>
        <Thumb Grid.Column="2" Grid.Row="2" Style="{DynamicResource ThumbSizeStyle}"/>

        <Canvas Visibility="Collapsed" Name="rotcanvas" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Thumb Name="rotarrowthumb" Canvas.Left="-2.5" DragDelta="Thumb_DragDelta">
                <Thumb.Template>
                    <ControlTemplate TargetType="Thumb">
                        <Border Width="5" Height="50" Background="Black" CornerRadius="0,0,40,40" />
                    </ControlTemplate>
                </Thumb.Template>
            </Thumb>
            <Thumb Name="rotcenterthumb" Canvas.Left="-7.5" Canvas.Top="-2.5" DragDelta="Thumb_DragDelta">
                <Thumb.Template>
                    <ControlTemplate TargetType="Thumb">
                        <Ellipse Width="15" Height="15" Fill="Black"  />
                    </ControlTemplate>
                </Thumb.Template>
            </Thumb>
        </Canvas>
    </Grid>
</UserControl>
